import { Component } from 'react'
import axios from 'axios'

function high(Com, url) {
    return class NewCom extends Component {
        state = {
            list: [],
            total: "",
            pageInfo: {
                // 每页多少条数据
                pageSize: 10,
                // 页数
                pageNum: 1
            }
        }
        pageChange = (num) => {
            let pageInfo = { ...this.state.pageInfo }
            pageInfo.pageNum = num
            this.setState({
                pageInfo
            }, () => {
                this.init()
            })
        }

        init = () => {
            // get传参
            axios.get(url, {
                params: {
                    ...this.state.pageInfo
                    // pageSize: this.state.pageInfo.pageSize,
                    // pageNum: this.state.pageInfo.pageNum,
                }
            }).then(res => {
                this.setState({
                    total: res.data.total,
                    list: res.data.res
                })
                console.log(res)
            })
        }
        render() {
            // console.log(this.state)
            return <div>
                <Com { ...this.state }/>
            </div>
        }
        componentDidMount() {
            this.init()
        }
    }
}

export {
    high
}
